<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Powered by 9416.cn</title>


<!--#include file="../inc/conn.asp"-->


<script type="text/javascript" src="../ui/jquery.js"></script>
 <link rel="stylesheet" href="../ui/layui/css/layui.css" type="text/css"  />
  <script src="../ui/echarts.min.js"></script>
<script type="text/javascript" src="../ui/layui/layui.js"></script>
  <script src="../ui/macarons.js"></script>


</head>
<style>
.chart_ip{
	width: 900px;
	height: 400px;
	
}
</style>

<body>


  
   <div class="mec_div" style="padding:20px;">
 <%jianbook.qxmsg()%>
   <div class="layui-tab" lay-filter="test">
  <ul class="layui-tab-title">
    <li class="layui-this" lay-id="11">访客统计</li>
    <li lay-id="22">访客图表统计</li>
    <li lay-id="33">来源排行</li>
    <li lay-id="44">访客列表</li>
   
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
   <table width="100%" border="0" cellspacing="0" cellpadding="0" class="layui-table">
 <thead>
  <tr>
    <td colspan="7" align="center"><strong>访客访问量统计</strong></td>
    </tr>
  <tr>
    <td>统计类型</td>
    <td>昨日</td>
    <td>今天</td>
    <td>本周</td>
    <td>本月</td>
    <td>本年</td>
    <td>全部</td>
  </tr>
  </thead>
  <tr>
    <td>IP</td>
    <td><%sql="select ip from [count] where datediff('d',intime,now())=1 group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&"<br>"
	rs.close
	%></td>
    <td><%sql="select ip from [count] where datediff('d',intime,now())=0 group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&"<br>"
	
	rs.close
	%></td>
    <td><%sql="select ip from [count] where datediff('ww',intime,now())=0 group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&"<br>"
	
	rs.close
			 
			 
			 
	%></td>
    <td><%sql="select ip from [count] where datediff('m',intime,now())=0 group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&"<br>"
	
	rs.close
			 
			 
			 
	%></td>
    <td><%sql="select ip from [count] where datediff('yyyy',intime,now())=0 group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&"<br>"
	
	rs.close
			 
			 
			 
	%></td>
    <td><%sql="select ip from [count]  group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&"<br>"
	
	rs.close
			 
			 
			 
	%></td>
  </tr>
  <tr>
    <td>PV</td>
    <td><%sql="select sum(pv)as tpv from [count] where datediff('d',intime,now())=1 "
	rs.open sql,conn,1,1
	response.Write rs("tpv")
	rs.close
	%></td>
    <td><%sql="select sum(pv)as tpv from [count] where datediff('d',intime,now())=0 "
	rs.open sql,conn,1,1
	response.Write rs("tpv")
	rs.close
	%></td>
    <td><%sql="select sum(pv)as tpv from [count] where datediff('ww',intime,now())=0 "
	rs.open sql,conn,1,1
	response.Write rs("tpv")
	rs.close
	%></td>
    <td><%sql="select sum(pv)as tpv from [count] where datediff('m',intime,now())=0 "
	rs.open sql,conn,1,1
	response.Write rs("tpv")
	rs.close
	%></td>
    <td><%sql="select sum(pv)as tpv from [count] where datediff('yyyy',intime,now())=0 "
	rs.open sql,conn,1,1
	response.Write rs("tpv")
	rs.close
	%></td>
    <td><%sql="select sum(pv)as tpv from [count] "
	rs.open sql,conn,1,1
	response.Write rs("tpv")
	rs.close
	%></td>
  </tr>
</table>

    </div>
    
  <div class="layui-tab-item" >
  
  
  <div id="chart_ip" class="chart_ip"></div></div>  
    <div class="layui-tab-item">
    
    <%if request.cookies("admin")("user")="admin" then%>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="layui-table">
 <thead>
  <tr>
    <td colspan="2" align="center"><strong>来源排行</strong></td>
    </tr>
  <tr>
    <td>来源</td>
    <td>次数</td>
    </tr>
  </thead><%
  sql="select url,count(*)as tnum from [count]  group by url order by count(*) desc "
	rs.open sql,conn,1,1
	do while not rs.eof
	
	%>
  <tr>
    <td><%=rs("url")%></td>
    <td><%=rs("tnum")%></td>
    </tr><%rs.movenext
  
  loop
  rs.close%>
  
 
</table>
<%else 
response.Write "没有权限"

end if%>
</div>


   
  <div class="layui-tab-item">
     <%if request.cookies("admin")("user")="admin" then%>
 <div class="layui-form ">
 
 
  <div class="layui-inline">
      
      <div class="layui-input-inline" style="width: 100px;">
        <input type="text" name="date_min" placeholder="开始日期" autocomplete="off" class="layui-input date">
      </div>
      <div class="layui-input-inline">-</div>
      <div class="layui-input-inline" style="width: 100px;">
        <input type="text" name="date_max" placeholder="结束日期" autocomplete="off" class="layui-input date">
      </div>
    </div>
  
  <div class="layui-inline">
 
    <input class="layui-input" name="key" id="demoReload" autocomplete="off" placeholder="输入要查询的ip">
    </div>
      
  <button class="layui-btn" data-type="reload">搜索</button>
</div>
 

 
<table class="layui-hide" id="table" lay-filter="demo"></table>
<%else 
response.Write "没有权限"

end if%>
  </div> 
   
   
   
  </div>
</div>
 
	
</div> 

 

<script>
	$(function(){
	var myChart = echarts.init(document.getElementById("chart_ip"),'macarons');
	
	myChart.setOption({
			title: {
				left: 'center',
				text: '最近10日访客统计'
			},
			tooltip: {
				trigger: 'axis'
			},
			legend: {
				bottom:0,
				
				textStyle:{
					color:'#123'
				},
				//orient:'vertical',
			
			},
			grid: {
				left: '0%',
				right: '0%',
				bottom: '10%',
				top:'10%',
				containLabel: true
			},
			
			
			xAxis: {
				type: 'category',
				boundaryGap: true,
				axisTick:{show:false},
				axisLabel:{
					textStyle:{
						color:"#666", //刻度颜色
						fontSize:12  //刻度大小
						}
				},
				axisLine:{
					show:true,
					lineStyle:{
						color: '#5FB878',
						width: 2,
						type: 'solid'
					}
				},
				splitLine:{
					show:true,
					lineStyle:{
						color: '#eee',
						width: 1,
						type: 'solid'
					}
				},
				data:[ <%
				
	 for i=0 to 9
	 D=9-i
	 response.Write "'"&month(DateAdd("d", -D, date()))&"-"&day(DateAdd("d", -d, date()))&"'"&","
	 
	  next   %> ]
			},
			yAxis: {
				
				type: 'value',
				axisTick:{show:false},
				axisLabel:{
					textStyle:{
						color:"#666", //刻度颜色
						fontSize:12  //刻度大小
						}
				},
				axisLine:{
					show:true,
					lineStyle:{
						color: '#5FB878',
						width: 2,
						type: 'solid'
					}
				},
				splitLine:{
					show:true
					
				}
				
				
			},
			series: [
						
						{
							name:'PV',
							type:'line',
							itemStyle : {  
									normal : {  
									color:'#006AD4'
								},
								lineStyle:{
									normal:{
									color:'#F3891B',
									opacity:1
										}
								}
							},
							data:[
  <%
	 for i=0 to 9
	 D=9-i
	 sql="select sum(pv)as tpv from [count] where datediff('d',intime,#"&DateAdd("d", -D, date())&"#)=0 "
	rs.open sql,conn,1,1
	if isnull(rs("tpv")) then
	response.Write "0,"
	else
	
	response.Write rs("tpv")&","
	end if
	
	rs.close
	 
	  next   %>
 
            ]
						},
						{
							name:'IP',
							type:'line',
							itemStyle : {  
									normal : {  
									color:'#009895'
								},
								lineStyle:{
									normal:{
									color:'#009895',
									opacity:1
										}
								}
							},
							data:[<%
	 for i=0 to 9
	 D=9-i
	 sql="select ip from [count] where datediff('d',intime,#"&DateAdd("d", -D, date())&"#)=0 group by ip"
	rs.open sql,conn,1,1
	response.Write rs.recordcount&","
	
	rs.close
	 
	 
	
	 
	  next   %>]
						}
					]
		}	
	);
})



</script>

<script>
layui.use('table', function(){
  var table = layui.table;

  //方法级渲染
  table.render({
    elem: '#table'
    ,url: '../inc/admin.asp?act=list'
	 ,toolbar: '#toolbarDemo'
    ,title: '用户数据表'
	,cellMinWidth: 100 
	
    ,cols: [[
	
	{field:'id', title: 'id',  sort: true}
     ,{field:'ip', title: 'ip',   sort: true}
	 ,{field:'addr', title: '地址',  sort: true}
	  ,{field:'pv', title: 'pv',  sort: true}
      ,{field:'url', title: '来源', sort: true}
      ,{field:'useragent', title: 'useragent', sort: false}
	
	  ,{field:'intime', title: '发布时间',  sort: true}
	 //  ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
     
	   
    ]]
    ,id: 'testReload'
    ,page: true
  ,limit:20
  });

  
  var $ = layui.$, active = {
    reload: function(){
      var demoReload = $('#demoReload');
      
      //执行重载
      table.reload('testReload', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
             date_min:  $('input[name=date_min]').val()
			  ,date_max:  $('input[name=date_max]').val()
			  ,key:  $('input[name=key]').val()
        }
		
      });
    }
  };
  
  $('.layui-form .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
  
  
   //监听行工具事件
  table.on('tool(demo)', function(obj){
    var data = obj.data;
   var pid=obj.data["id"]
    if(obj.event === 'del'){
    layer.confirm('真的删除行么', function(index){
        $.ajax({
			type : "POST",
			cache : true,
			url : "ajax.asp?act=dell",
			data:{"table":'list',"id":pid},
			success:function(data)
	{var act=data.substring(0,1);
		var info=data.substring(1);
		switch(act)
		{
		case "1":
	      obj.del();
			break;
		}
	}
	});
	 layer.close(index);
      });
	  
    } else if(obj.event === 'edit'){
     
	 tc('修改信息','edit.asp?id='+pid,800,600)
	 
    }
  });
  
  
  
  
  
  

});
</script>




<script type="text/javascript" src="../ui/pc.js"></script>	

</body>

</html>
